Show:

Streams chat Class

Chatroom for people chat in a stream that allows posting messages with type "Streams/chat/message"

Constructor

Streams chat

(
  • [options]
)

Parameters:

  • [options] Object optional

    this object contains function parameters

    • [publisherId] String optional

      Required if stream option is empty. The publisher's user id.

    • [streamName] String optional

      Required if stream option is empty. The stream's name.

    • [stream] Stream optional

      Optionally pass a Streams.Stream object here if you have it already

    • [stream] Stream optional

      Optionally pass a Streams.Stream object here if you have it already

    • [inputType="text"] Stream optional

      Can be either "text" or "textarea"

    • [messagesToLoad] String optional

      The number of "Streams/chat" messages to load at a time.

    • [messageMaxHeight] String optional

      The maximum height, in pixels, of a rendered message

    • [animations] String optional

      Options for animations, which can include:

      • [duration=300] String optional
        The duration of the animation
    • [controls={}] Object optional

      Controls to show next to each chat message

      • [up] Boolean | Array optional
        Can be true or an array of [off, on] image urls.
      • [down] Boolean | Array optional
        Can be true or an array of [off, on] image urls.
      • [flag] Boolean | Array optional
        Can be true or an array of [off, on] image urls.
    • [loadMore] Object optional

      May be "scroll", "click" or null/false. Defaults to "click".

      • "click" will show label with "Click to see earlier messages" (configurable in Q.text.Streams.chat.loadMore.click string), and when the user clicks it, new messages will be loaded.
      • "scroll" means new messages will be loaded when the scrollbar of the chat container reaches the top (for desktop) or whole document scrollbar reaches the top (android). On all other browsers it would use pull-to-refresh ... meaning, it will show "Pull to see earlier messages" (html configurable in Q.text.Streams.chat.loadMore.pull string) and as you pull "too far" you trigger the load. As for the indicator of "pulling too far", we will worry about that later, for now skip it. But remember to discuss it with me afterwards.
      • null/false/etc. - no interface to load earlier messages

    • [onRefresh] Q.Event optional

      Event for when an the chat has been updated

    • [onError] Q.Event optional

      Event for when an error occurs, and the error is passed

    • [onClose] Q.Event optional

      Event for when chat stream closed

Methods

prevent Disables the textarea, preventing the user from writing a message using the provided interface. They are still able to POST to the server, however, e.g. manually.

(
  • message
)
HTMLElement

Parameters:

  • message String | False

    The text to display in the placeholder of the textarea while input is prevented. Pass false here to re-enable the textarea.

Returns:

HTMLElement:

the div that replaces the textarea